import axios from 'axios'
import { message } from 'antd';

// const isDev = process.env.NODE_ENV === 'development'

const service = axios.create({
    baseURL: 'http://rap2api.taobao.org/app/mock/274306'
})

service.interceptors.request.use(config=>{
    return config
})

service.interceptors.response.use(res=>{

    if(res.data.code===200) {
        
        return res.data.data
    }else{
        message.error('获取失败')
    }
})

export const getArtical = (offset, limit) => {
    return service.post('/api/v1/artical', {offset, limit})
}

export const deleteArticalRequest = (id) => {
    return service.post(`/api/v1/artical_delete/${id}`)
}


export const getArticalRequest = (id) => {
    return service.post(`/api/v1/artical/${id}`)
}

export const editArticalRequest = (id, data) => {
    return service.post(`/api/v1/artical_edit/${id}`, data)
}

export const articalAmount = (id, data) => {
    return service.post(`/api/v1/artical_amount`)
}

export const getNoticicationList = () => {
    return service.post('/api/v1/notifications')
}

export const loginRequest = (userInfo) => {
    return service.post('/api/v1/login', userInfo)
}